export const getSetting = () => {
  return new Promise((reslove, reject) => {
    //获取用户授权状态
    wx.getSetting({
      success: result => {
        reslove(result);
      },
      fail: err => {
        reject(err);
      }
    });
  });
};
export const openSetting = () => {
  return new Promise((reslove, reject) => {
    //诱导用户打开用户授权
    wx.openSetting({
      success: result => {
        reslove(result);
      },
      fail: err => {
        reject(err);
      }
    });
  });
};
export const chooseAddress = () => {
  return new Promise((reslove, reject) => {
    //选择收货地址
    wx.chooseAddress({
      success: result => {
        reslove(result);
      },
      fail: err => {
        reject(err);
      }
    });
  });
};

//用户提示框
export const showModel = ({ content }) => {
  return new Promise((reslove, reject) => {
    wx.showModal({
      title: "提示",
      content: content,
      success: result => {
        reslove(result);
      },
      fail: err => {
        console.log(err);
      }
    });
  });
};

//弹框提示
export const showToast = ({ title }) => {
  return new Promise((reslove, reject) => {
    wx.showToast({
      title: title,
      icon: "none"
    });
  });
};

//微信登录获取token
export const wxLogin = () => {
  return new Promise((reslove, reject) => {
    wx.login({
      timeout: 10000,
      success: result => {
        reslove(result);
      },
      fail: err => {
        console.log(err);
      }
    });
  });
};
